<template>
  <div>
    <div class="detailnav">
      <span>首页</span> &gt;
      <span
        ><span v-for="item in infoData.categories.reverse()" :key="item.id"
          >{{ item.name }} &gt;</span
        >
      </span>
      <span>{{ infoData.name }}</span>
    </div>
    <div class="detail_wrap">
      <div class="detail_left">
        <zoom :mainPictures="infoData.mainPictures"></zoom>
      </div>
      <div class="detail_right">
        <!-- 详情基本信息 -->
        <base-info :infoData="infoData"></base-info>
      </div>
    </div>
    <same-goods :title="'同类商品推荐'"></same-goods>
    <!-- 详情大图和24小时热榜组件 -->
    <detail-bottom :details="infoData.details"></detail-bottom>
  </div>
</template>
<script>
import zoom from './child/zoom.vue'
import baseInfo from './child/baseinfo.vue'
import sameGoods from './child/sameGoods.vue'
import detailBottom from './child/detail_bottom.vue'
import { _getDetail } from '../../api/detail'
export default {
  components: { zoom, baseInfo, sameGoods, detailBottom },
  data () {
    return {
      id: '',
      infoData: {} //整个详情页需要的数据
    }
  },
  created () {
    // 接受上个页面传来的参数
    this.id = this.$route.query.id
    console.log(this.id)
    this.getDetail()
  },
  methods: {
    // 获取详情页的接口
    async getDetail () {
      var res = await _getDetail(this.id)
      console.log(res)
      this.infoData = res.data.result
    }
  }
}
</script>
<style lang="less">
.detailnav {
  width: 1240px;
  margin: 20px auto;
  font-size: 20px;
}
.detail_wrap {
  width: 1240px;
  margin: 0 auto;
  display: flex;
  .detail_right {
    margin-left: 40px;
    width: 660px;
  }
}
</style>
